<link rel="stylesheet" type="text/css" href="{$smarty.const.THEME_RELATIVE}modules/documentsmodule/css/sermonmodule.css" />
<script type="text/javascript" src="/themes/kcms_edit/js/jquery.scrollTo-1.4.2-min.js"></script>

<div class="textmodule">
    <div class="textmodule_title">
        <h3>{$moduletitle}</h3>
    </div>
</div>

{assign var="contact_text_src" value="documents_`$smarty.const.LANG`"}
{chain module="textmodule" view="Kurtulus Credit - Black Header" src=$contact_text_src }

{permissions level=$smarty.const.UILEVEL_PERMISSIONS}
          {if $permissions.administrate == 1}
            <a href="{link action=userperms _common=1}"><img src="{$smarty.const.ICON_RELATIVE}userperms.png" title="{$_TR.alt_userperm}" alt="{$_TR.alt_userperm}" /></a>
            <a href="{link action=groupperms _common=1}"><img src="{$smarty.const.ICON_RELATIVE}groupperms.png" title="{$_TR.alt_groupperm}" alt="{$_TR.alt_groupperm}" /></a>
        {/if}
        {if $permissions.configure == 1}
                <a href="{link action=configure _common=1}"><img src="{$smarty.const.ICON_RELATIVE}configure.png" title="{$_TR.alt_configure}" alt="{$_TR.alt_configure}" /></a>
        {/if}
        {if $permissions.configure == 1 or $permissions.administrate == 1}
            <br />
        {/if}
        {if $permissions.create == 1 or $permissions.administrate == 1}                 
            <a href="{link action=manage module=documentsmodule}">{$_TR.managedoc}</a>
        {/if}
{/permissions}

 {assign var="start" value=$start_pos}   
<div class="sermonmodule">
	<table class="sermon_table">
		{foreach name=a from=$sermons item=sermon}
              {assign var="start" value=$start+1}
			<tr class="{cycle values='even,odd'}">
                <td width="15px" ><span class="sermon_name">{$start}.</span></td>
				<td>
					<span class="sermon_name"><a href="#{$sermon->name}">{$sermon->name}</a></span>
					{permissions level=$smarty.const.UILEVEL_PERMISSIONS}
						{if $permissions.edit ==1 or $permissions.administrate ==1}
						<a href="{link action=edit id=$sermon->id}" title="{$_TR.editentry}"><img src="{$smarty.const.ICON_RELATIVE}edit.png" title="{$_TR.alt_edit}" alt="{$_TR.alt_edit}" /></a>{/if}
						{if $permissions.delete ==1 or $permissions.administrate ==1}
						<a href="{link action=delete id=$sermon->id}" title="{$_TR.delentry}"><img src="{$smarty.const.ICON_RELATIVE}delete.png" title="{$_TR.alt_delete}" alt="{$_TR.alt_delete}" /></a>
						{/if}
					{/permissions}
                    <span class="sermon_author">{$sermon->author}</span>
                    <br>
                    <div class="series">{$sermon->series_name}</div>
				</td>
				
				<td class="sermon_number">
                    {if $sermon->doc_file > 0}
                        <a href="/download_file.php?id={$sermon->doc_file}" target=_blank><img src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/file_doc.jpg' border=0></a>
                    {/if}
                    {if $sermon->xls_file > 0}
                        <a href="/download_file.php?id={$sermon->xls_file}" target=_blank><img src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/file_xls.png' border=0></a>
                    {/if}
					{if $sermon->ppt_file > 0}
                        <a href="/download_file.php?id={$sermon->ppt_file}" target=_blank><img  src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/file_ppt.png' border=0></a>
                    {/if}
					{if $sermon->pdf_file > 0}
						<a href="/download_file.php?id={$sermon->pdf_file}" target=_blank><img src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/file_pdf.png' border=0></a>
					{/if}
					
					{if $sermon->mp3_file > 0}
						<a href="/download_file.php?id={$sermon->mp3_file}" target=_blank><img  src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/music.jpg' border=0></a>
					{/if}
                    {if $sermon->flv_file > 0}
                        <a href="/download_file.php?id={$sermon->flv_file}" target=_blank><img  src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/file_flv.jpg    ' border=0></a>
                    {/if}
                     <div class="series">{$sermon->create_date}</div>
				</td>
				<td class="sermon_number" style="text-align: right;"><a name="{$sermon->name}">{$sermon->download}&nbsp;<img src='{$smarty.const.THEME_RELATIVE}modules/documentsmodule/images/download.png' border=0></a>
				</td>
			</tr>
		{foreachelse}
			<tr class="odd">
				<td colspan=4 class="sermon_number">{$_TR.no_sermon}</td>
			</tr>
		{/foreach}
	</table>
	<br>
	<div align=center>{paging current_page=$page pages=$pages action=view_page module=documentsmodule page_length=4 src=$__loc->src}</div>
</div>

<script language="javascript">
    function goto_anchor_by_href()
    {ldelim}
        // get hash
        var hash = window.location.hash;
        if (hash == "")
            return;
        hash=hash.substring(1);
        var item=jQuery(".sermon_table a[name='"+hash+"']");
        
        $.scrollTo( item, 800, {ldelim} top: '-=50px'{rdelim} );
    {rdelim}
    
    jQuery(document).ready(function() {ldelim}    
        jQuery(".sermon_name a").click(function() {ldelim}
            return false;
        {rdelim})
        goto_anchor_by_href();
        
    {rdelim});
</script>